var _gaq = _gaq || [];

    _gaq.push(['_setAccount', 'UA-1445944-1']);
    _gaq.push(['_trackPageview']);
    _gaq.push(['_setDomain', 'car.gr']);


    (function() {
    var ga = document.createElement('script');
    ga.src = ('https:' == document.location.protocol ?
        'https://ssl' : 'http://www') +
        '.google-analytics.com/ga.js';
    ga.setAttribute('async', 'true');
    document.documentElement.firstChild.appendChild(ga);
    })();

var addthis_config = {
                         ui_click: true,
                        // data_track_clickback: true,
                         data_ga_property: 'UA-1445944-4',
                         data_ga_social: true,
                         ui_language: "el"
                    };
                    var addthis_share = {
                         url: "http://www.car.gr/d6134859",
                         title: "Ν&amp;Α ΑΣΗΜΑΚΟΠΟΥΛΟΣ Ο.Ε"
                    }
                    var addthis_localize = {
                        share_caption: "Μοίρασε με φίλους"
                    };

if (window.parent.o87tnbi8ti76rvu7fbi87btru65bi8tbi76rbi78tn87otbi76rt != undefined) {
        window.parent.o87tnbi8ti76rvu7fbi87btru65bi8tbi76rbi78tn87otbi76rt();
    }

function get_back(elem) {
    var bg = $(elem).css('background-image');
    bg = bg.replace('url(','').replace(')','').replace('"','');
    $(elem).css('background-image','none');
    return bg;
}


function get_position() {
    var pos = $('#header_image_1 img').css('left');
    return pos;
}

function position_back2() {
        var width = $( window ).width();
        var left=(width/2+ 1080/2)-$('#header_image_1 .ie_hack2').width()-20;
        $('#header_image_1 .ie_hack2').css('left',left);
}

$(document).ready(function() {

    if ($("html").hasClass("ie8")) {
        var height = $('#header_image_1').height();
        var back = get_back('#header_image_1');
        if (back != 'none') {
            var img = '<img class="ie_hack" height="'+height+'px;"  src="'+back+'"/>'
            $('#header_image_1').prepend(img);
            position = get_position();
            if (position != '0px'){
                width = $('#header_image_1 .ie_hack').width();
                left = parseInt(position) - width/2;
                $('#header_image_1 .ie_hack').css('left',left);
            }
            else {
                $('#header_image_1 .ie_hack').css('left','auto');
            }
        }

        var back2 = get_back('#header_image_2');
        if (back2 != 'none'){
            var img = '<img class="ie_hack2" height="'+height+'px;"  src="'+back2+'"/>'
            $('#header_image_1').append(img);
            position_back2();

        }

        if( $("html").hasClass("ie6") ) {
                var h_back=get_back("#header");
                $('#header_text_container').css('background','url("'+h_back+')');
        }
        $('#header_image_2').hide();

    }

    $( window ).resize(function() {
      position_back2();
    });

     $( ".dropdown" ).on('click', function() {
        $(this).toggleClass('open');
     });

});

function show_video() {
    document.getElementById("clsfd_photo_6134859").style.display ='none';
    document.getElementById("player").style.display ='block';
}
function stop_video() {
    document.getElementById("player").style.display ='none';
    document.getElementById("clsfd_photo_6134859").style.display ='inline';
}
function checkrange(val, min, max, msg) {
    if (val < min || val > max) {
        alert(msg + ' ' + 'πρέπει να είναι ανάμεσα' + " [" + min + ".." + max + "]");
        return false;
    }
return true;
}

function currency_format(x) {
    var d = ''+Math.round(parseFloat(x)*100);
    for (i = d.length-5; i > 0; i -= 3) {
        d = d.substring(0, i) + '.' + d.substring(i, d.length);
        }
    return d.substring(0, d.length-2) + ',' + d.substring(d.length-2, d.length);
}

function change_pic(ele, id, user_photo) {
    $(".thumbnail").removeClass('alert-info');
    $(ele).toggleClass('alert-info');
        var i = document.getElementById('clsfd_photo_6134859');
        if (!user_photo){
            i.src = 'http://s19.carcdn.gr/6134/6134859_%i_n.jpg'.replace('%i', id);
        }
        else {
            i.src = 'http://userdata.carcdn.gr/%i'.replace('%i', id);
        }
        return false;
    }